﻿@page "/system_manager/function"
@inherits TableBase<FunctionDto, Guid, FunctionEdit>
<div>
    <Table @ref="_table"
           TItem="FunctionDto"
           DataSource="@_datas"
           Total="_total"
           OnChange="@OnChange"
           @bind-PageIndex="_pageIndex"
           @bind-PageSize="_pageSize"
           @bind-SelectedRows="_selectedRows"
           Loading="@_tableIsLoading"
           Context="model"
            >
        <TitleTemplate>
            <ResourceAuthorize ResourceKey="system_manager_function_refresh">
                <TableSearch TDto="FunctionDto" OnSearchFieldChanged="SetPresetFilterGroups" OnSearch="()=>ReLoadTable(true)" DefaultValue="_defaultSearchValue"></TableSearch>
             </ResourceAuthorize>
            <Row>
                <AntDesign.Col Span="8">
                    <ResourceAuthorize ResourceKey="system_manager_function_delete_selected">
                        <Button Type="@ButtonType.Primary" Icon="delete" Danger OnClick="OnClickDeletes" Loading="_deletesBtnLoading">
                            @localizer["删除选中"]
                        </Button>
                    </ResourceAuthorize>
                </AntDesign.Col>
                <AntDesign.Col Span="16" Style="text-align:right">
                    <Space>
                        <ResourceAuthorize ResourceKey="system_manager_function_import">
                            <SpaceItem>
                                <Button Type="@ButtonType.Primary" Icon="import" OnClick="OnImportClick">
                                    @localizer["导入"]
                                </Button>
                            </SpaceItem>
                        </ResourceAuthorize>
                        @*<ResourceAuthorize ResourceKey="system_manager_function_add">
                            <SpaceItem>
                                <Button Type="@ButtonType.Primary" Icon="plus" OnClick="OnAddClick">
                                    添加
                                </Button>
                            </SpaceItem>
                        </ResourceAuthorize>*@

                        <ResourceAuthorize ResourceKey="system_manager_function_refresh">
                            <SpaceItem>
                                <Button Type="@ButtonType.Primary" Icon="reload" OnClick="ReLoadTable">
                                    @localizer["刷新"]
                                </Button>
                            </SpaceItem>
                        </ResourceAuthorize>
                        <ResourceAuthorize ResourceKey="system_manager_function_download_seed_data">
                            <SpaceItem>
                                <Button Type="@ButtonType.Primary" Icon="download" OnClick="OnClickShowSeedData<ShowSeedDataCode>">
                                    @localizer["种子数据"]
                                </Button>
                            </SpaceItem>
                        </ResourceAuthorize>
                    </Space>
                </AntDesign.Col>
            </Row>

        </TitleTemplate>
        <RowTemplate>
            <ResourceAuthorize ResourceKey="system_manager_function_delete_selected">
                <Selection Key="@(model.Id.ToString())" Width="5%" />
            </ResourceAuthorize>
            <Column @bind-Field="@model.Group" Width="10%" Filterable />
            <Column @bind-Field="@model.Service" Width="10%" Filterable />
            <Column @bind-Field="@model.Summary" Width="10%" Filterable />
            <Column @bind-Field="@model.Path" Width="60" Filterable />
            <Column @bind-Field="@model.Method" Width="10%" Filters="TableFiltersConstants.FunctionMethodFilters">
                <TagRandomColor Text="@EnumHelper.GetEnumDescription(model.Method)"></TagRandomColor>
            </Column>
            <Column @bind-Field="@model.EnableAudit" Width="8%" Filterable>
                <ResourceAuthorize ResourceKey="system_manager_function_enable_audit">
                    <Authorized>
                        <Switch @bind-Value="@model.EnableAudit" OnChange="e=>OnChangeEnableAudit(model,e)"></Switch>
                    </Authorized>
                    <NotAuthorized>
                        <TagYesNo Yes="model.EnableAudit"></TagYesNo>
                    </NotAuthorized>
                </ResourceAuthorize>
            </Column>
            <Column @bind-Field="@model.IsLocked" Width="8%" Filterable>
                <ResourceAuthorize ResourceKey="system_manager_function_lock">
                    <Authorized>
                        <Switch @bind-Value="@model.IsLocked" OnChange="e=>OnChangeIsLocked(model,e)"></Switch>
                    </Authorized>
                    <NotAuthorized>
                        <TagYesNo Yes="model.IsLocked"></TagYesNo>
                    </NotAuthorized>
                </ResourceAuthorize>
            </Column>
            <Column @bind-Field="@model.CreatedTime" Format="@ClientConstant.DateTimeFormat" Sortable Width="10%" DefaultSortOrder="@SortDirection.Descending" />
            <ActionColumn Width="10%">
                <Space>
                    <ResourceAuthorize ResourceKey="system_manager_function_edit">
                        <SpaceItem>
                            <Tooltip Title="@(localizer["编辑"])" ArrowPointAtCenter="true">
                                <Button Icon="edit" Type="@ButtonType.Primary" Size="@ClientConstant.OperationButtonSize" OnClick="()=>OnClickEdit(model.Id)"></Button>
                            </Tooltip>
                        </SpaceItem>
                    </ResourceAuthorize>
                    <ResourceAuthorize ResourceKey="system_manager_function_detail">
                        <SpaceItem>
                            <Tooltip Title="@(localizer["详情"])" ArrowPointAtCenter="true">
                                <Button Icon="eye" Type="@ButtonType.Primary" Size="@ClientConstant.OperationButtonSize" OnClick="()=>OnClickDetail(model.Id)"></Button>
                            </Tooltip>
                        </SpaceItem>
                    </ResourceAuthorize>
                    <ResourceAuthorize ResourceKey="system_manager_function_delete">
                        <SpaceItem>
                            <Tooltip Title="@(localizer["删除"])" ArrowPointAtCenter="true">
                                <Button Icon="delete" Type="@ButtonType.Primary" Danger OnClick="()=>OnClickDelete(model.Id)"></Button>
                            </Tooltip>
                        </SpaceItem>
                    </ResourceAuthorize>
                </Space>
            </ActionColumn>
        </RowTemplate>
    </Table>
</div>